/*
   SignatureCaptureControl.cpp
   
   Copyright (C) 2006 LinuxOne, Inc. <Republic of korea>

   This library is free software; you can redistribute it and/or modify
   it under the terms of the GNU Lesser General Public License as
   published by the Free Software Foundation; either version 2.1
   of the License, or (at your option) any later version.

   This library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of 
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
   Lessor General Public License for more details.

   You should have received a copy of the GNU Lessor General Public
   License along with this library; if not, write to the Free Software
   Foundation, inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

   Hyunjin Kim <mgc521@linuxone.co.kr>

   LinuxOne, Inc., hereby disclaims all copylight
   written by Hyunjin Kim, 20 December 2006
*/

#include <control/SignatureCaptureControl.h>

namespace booyopos
{

CSignatureCapture::CSignatureCapture()
{
	deviceControlDescription = "BooyoPOS SignatureCapture Device Control";
	deviceControlVersion = 0;

	cscs= new services::CSignatureCaptureService;

	CBaseControl::bs=dynamic_cast<services::CBaseService *>(cscs);
}

CSignatureCapture::~CSignatureCapture()
{
}

/* Capabilities */
bool
CSignatureCapture::GetCapDisplay()
throw (CByException)
{
	try
	{
		if(!bOpen)
		{
			throw CByException(E_CLOSED, "Control not opened");
		}
	
		return cscs->capDisplay;
	}
	catch(CByException bye)
	{
		throw bye;
	}
	catch(std::exception e)
	{
		throw CByException(E_CLOSED, "Unhandled exception from Device Service", e);
	}
}

bool
CSignatureCapture::GetCapRealTimeData()
throw (CByException)
{
	try
	{
		if(!bOpen)
		{
			throw CByException(E_CLOSED, "Control not opened");
		}
	
		return cscs->capRealTimeData;
	}
	catch(CByException bye)
	{
		throw bye;
	}
	catch(std::exception e)
	{
		throw CByException(E_CLOSED, "Unhandled exception from Device Service", e);
	}
}

bool
CSignatureCapture::GetCapUserTerminated()
throw (CByException)
{
	try
	{
		if(!bOpen)
		{
			throw CByException(E_CLOSED, "Control not opened");
		}
	
		return cscs->capUserTerminated;
	}
	catch(CByException bye)
	{
		throw bye;
	}
	catch(std::exception e)
	{
		throw CByException(E_CLOSED, "Unhandled exception from Device Service", e);
	}
}

int
CSignatureCapture::GetCapPowerReporting()
throw (CByException)
{
	try
	{
		if(!bOpen)
		{
			throw CByException(E_CLOSED, "Control not opened");
		}
	
		return cscs->capPowerReporting;
	}
	catch(CByException bye)
	{
		throw bye;
	}
	catch(std::exception e)
	{
		throw CByException(E_CLOSED, "Unhandled exception from Device Service", e);
	}
}

bool
CSignatureCapture::GetCapStatisticsReporting()
throw (CByException)
{
	try
	{
		if(!bOpen)
		{
			throw CByException(E_CLOSED, "Control not opened");
		}
	
		return cscs->capStatisticsReporting;
	}
	catch(CByException bye)
	{
		throw bye;
	}
	catch(std::exception e)
	{
		throw CByException(E_CLOSED, "Unhandled exception from Device Service", e);
	}
}

bool
CSignatureCapture::GetCapUpdateStatistics()
throw (CByException)
{
	try
	{
		if(!bOpen)
		{
			throw CByException(E_CLOSED, "Control not opened");
		}
	
		return cscs->capUpdateStatistics;
	}
	catch(CByException bye)
	{
		throw bye;
	}
	catch(std::exception e)
	{
		throw CByException(E_CLOSED, "Unhandled exception from Device Service", e);
	}
	return 1;
}

bool
CSignatureCapture::GetCapCompareFirmwareVersion()
throw (CByException)
{
	try
	{
		if(!bOpen)
		{
			throw CByException(E_CLOSED, "Control not opened");
		}
	
		return cscs->capCompareFirmwareVersion;
	}
	catch(CByException bye)
	{
		throw bye;
	}
	catch(std::exception e)
	{
		throw CByException(E_CLOSED, "Unhandled exception from Device Service", e);
	}
}

bool
CSignatureCapture::GetCapUpdateFirmware()
throw (CByException)
{
	try
	{
		if(!bOpen)
		{
			throw CByException(E_CLOSED, "Control not opened");
		}
	
		return cscs->capUpdateFirmware;
	}
	catch(CByException bye)
	{
		throw bye;
	}
	catch(std::exception e)
	{
		throw CByException(E_CLOSED, "Unhandled exception from Device Service", e);
	}
}

/* Properties */
bool
CSignatureCapture::GetAutoDisable()
throw (CByException)
{
	try
	{
		if(!bOpen)
		{
			throw CByException(E_CLOSED, "Control not opened");
		}
	
		return cscs->autoDisable;
	}
	catch(CByException bye)
	{
		throw bye;
	}
	catch(std::exception e)
	{
		throw CByException(E_CLOSED, "Unhandled exception from Device Service", e);
	}
}

void
CSignatureCapture::SetAutoDisable(bool autoDisable)
throw (CByException)
{
	try
	{
		if(!bOpen)
		{
			throw CByException(E_CLOSED, "Control not opened");
		}
	
		cscs->SetAutoDisable(autoDisable);
	}
	catch(CByException bye)
	{
		throw bye;
	}
	catch(std::exception e)
	{
		throw CByException(E_CLOSED, "Unhandled exception from Device Service", e);
	}
}

int
CSignatureCapture::GetDataCount()
throw (CByException)
{
	try
	{
		if(!bOpen)
		{
			throw CByException(E_CLOSED, "Control not opened");
		}
	
		return cscs->dataCount;
	}
	catch(CByException bye)
	{
		throw bye;
	}
	catch(std::exception e)
	{
		throw CByException(E_CLOSED, "Unhandled exception from Device Service", e);
	}
}

bool
CSignatureCapture::GetDataEventEnabled()
throw (CByException)
{
	try
	{
		if(!bOpen)
		{
			throw CByException(E_CLOSED, "Control not opened");
		}
	
		return cscs->dataEventEnabled;
	}
	catch(CByException bye)
	{
		throw bye;
	}
	catch(std::exception e)
	{
		throw CByException(E_CLOSED, "Unhandled exception from Device Service", e);
	}
}

void
CSignatureCapture::SetDataEventEnabled(bool dataEventEnabled)
throw (CByException)
{
	try
	{
		if(!bOpen)
		{
			throw CByException(E_CLOSED, "Control not opened");
		}
	
		cscs->SetDataEventEnabled(dataEventEnabled);
	}
	catch(CByException bye)
	{
		throw bye;
	}
	catch(std::exception e)
	{
		throw CByException(E_CLOSED, "Unhandled exception from Device Service", e);
	}
}

int
CSignatureCapture::GetMaximumX()
throw (CByException)
{
	try
	{
		if(!bOpen)
		{
			throw CByException(E_CLOSED, "Control not opened");
		}
	
		return cscs->maximumX;
	}
	catch(CByException bye)
	{
		throw bye;
	}
	catch(std::exception e)
	{
		throw CByException(E_CLOSED, "Unhandled exception from Device Service", e);
	}
}

int
CSignatureCapture::GetMaximumY()
throw (CByException)
{
	try
	{
		if(!bOpen)
		{
			throw CByException(E_CLOSED, "Control not opened");
		}
	
		return cscs->maximumY;
	}
	catch(CByException bye)
	{
		throw bye;
	}
	catch(std::exception e)
	{
		throw CByException(E_CLOSED, "Unhandled exception from Device Service", e);
	}
}

char*
CSignatureCapture::GetRawData()
throw (CByException)
{
	try
	{
		if(!bOpen)
		{
			throw CByException(E_CLOSED, "Control not opened");
		}
	
		return cscs->rawData;
	}
	catch(CByException bye)
	{
		throw bye;
	}
	catch(std::exception e)
	{
		throw CByException(E_CLOSED, "Unhandled exception from Device Service", e);
	}
}

bool
CSignatureCapture::GetRealTimeDataEnabled()
throw (CByException)
{
	try
	{
		if(!bOpen)
		{
			throw CByException(E_CLOSED, "Control not opened");
		}
	
		return cscs->realTimeDataEnabled;
	}
	catch(CByException bye)
	{
		throw bye;
	}
	catch(std::exception e)
	{
		throw CByException(E_CLOSED, "Unhandled exception from Device Service", e);
	}
	return 1;
}

void
CSignatureCapture::SetRealTimeDataEnabled(bool realTimeDataEnabled)
throw (CByException)
{
	try
	{
		if(!bOpen)
		{
			throw CByException(E_CLOSED, "Control not opened");
		}
	
		cscs->SetRealTimeDataEnabled(realTimeDataEnabled);
	}
	catch(CByException bye)
	{
		throw bye;
	}
	catch(std::exception e)
	{
		throw CByException(E_CLOSED, "Unhandled exception from Device Service", e);
	}
}

int
CSignatureCapture::GetPowerNotify()
throw (CByException)
{
	try
	{
		if(!bOpen)
		{
			throw CByException(E_CLOSED, "Control not opened");
		}
	
		return powerNotice;
	}
	catch(CByException bye)
	{
		throw bye;
	}
	catch(std::exception e)
	{
		throw CByException(E_CLOSED, "Unhandled exception from Device Service", e);
	}
}

void
CSignatureCapture::SetPowerNotify(int powerNotice)
throw (CByException)
{
	try
	{
		if(!bOpen)
		{
			throw CByException(E_CLOSED, "Control not opened");
		}
	
		cscs->SetPowerNotify(powerNotice);
	}
	catch(CByException bye)
	{
		throw bye;
	}
	catch(std::exception e)
	{
		throw CByException(E_CLOSED, "Unhandled exception from Device Service", e);
	}
}

int
CSignatureCapture::GetPowerState()
throw (CByException)
{
	try
	{
		if(!bOpen)
		{
			throw CByException(E_CLOSED, "Control not opened");
		}
	
		return cscs->powerState;
	}
	catch(CByException bye)
	{
		throw bye;
	}
	catch(std::exception e)
	{
		throw CByException(E_CLOSED, "Unhandled exception from Device Service", e);
	}
}

/* Method */
void
CSignatureCapture::BeginCapture(std::string formName)
throw (CByException)
{
	try
	{
		if(!bOpen)
		{
			throw CByException(E_CLOSED, "Control not opened");
		}
	
		cscs->BeginCapture(formName);
	}
	catch(CByException bye)
	{
		throw bye;
	}
	catch(std::exception e)
	{
		throw CByException(E_CLOSED, "Unhandled exception from Device Service", e);
	}
}

void
CSignatureCapture::EndCapture()
throw (CByException)
{
	try
	{
		if(!bOpen)
		{
			throw CByException(E_CLOSED, "Control not opened");
		}
	
		cscs->EndCapture();
	}
	catch(CByException bye)
	{
		throw bye;
	}
	catch(std::exception e)
	{
		throw CByException(E_CLOSED, "Unhandled exception from Device Service", e);
	}
}

/*		*/
void
CSignatureCapture::ClearInput()
throw (CByException)
{
	try
	{
		if(!bOpen)
		{
			throw CByException(E_CLOSED, "Control not opened");
		}
	
		cscs->ClearInput();
	}
	catch(CByException bye)
	{
		throw bye;
	}
	catch(std::exception e)
	{
		throw CByException(E_CLOSED, "Unhandled exception from Device Service", e);
	}
}

void
CSignatureCapture::ClearInputProperties()
throw (CByException)
{
	try
	{
		if(!bOpen)
		{
			throw CByException(E_CLOSED, "Control not opened");
		}
	
		cscs->ClearInputProperties();
	}
	catch(CByException bye)
	{
		throw bye;
	}
	catch(std::exception e)
	{
		throw CByException(E_CLOSED, "Unhandled exception from Device Service", e);
	}
}

/* Statistics */
void
CSignatureCapture::ResetStatistics(std::string statisticsBuffer)
throw (CByException)
{
	try
	{
		if(!bOpen)
		{
			throw CByException(E_CLOSED, "Control not opened");
		}
	
		cscs->ResetStatistics(statisticsBuffer);
	}
	catch(CByException bye)
	{
		throw bye;
	}
	catch(std::exception e)
	{
		throw CByException(E_CLOSED, "Unhandled exception from Device Service", e);
	}
}

void
CSignatureCapture::RetrieveStatistics(std::string statisticsBuffer[])
throw (CByException)
{
	try
	{
		if(!bOpen)
		{
			throw CByException(E_CLOSED, "Control not opened");
		}
	
		cscs->RetrieveStatistics(statisticsBuffer);
	}
	catch(CByException bye)
	{
		throw bye;
	}
	catch(std::exception e)
	{
		throw CByException(E_CLOSED, "Unhandled exception from Device Service", e);
	}
}

void
CSignatureCapture::UpdateStatistics(std::string statisticsBuffer)
throw (CByException)
{
	try
	{
		if(!bOpen)
		{
			throw CByException(E_CLOSED, "Control not opened");
		}
	
		cscs->UpdateStatistics(statisticsBuffer);
	}
	catch(CByException bye)
	{
		throw bye;
	}
	catch(std::exception e)
	{
		throw CByException(E_CLOSED, "Unhandled exception from Device Service", e);
	}
}

void
CSignatureCapture::UpdateFirmware(std::string firmwareFileName)
throw (CByException)
{
	try
	{
		if(!bOpen)
		{
			throw CByException(E_CLOSED, "Control not opened");
		}
	
		cscs->UpdateFirmware(firmwareFileName);
	}
	catch(CByException bye)
	{
		throw bye;
	}
	catch(std::exception e)
	{
		throw CByException(E_CLOSED, "Unhandled exception from Device Service", e);
	}
}

} // namespace booyopos
